package com.capgemini.cn.authority.rest.valueobject;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * Created at 2017/9/15
 *
 * @param <D> 响应给客户端的具体业务数据对象
 * @author Andriy
 */
@ApiModel(value = "响应客户端统一对象结构")
@JsonSerialize
@JsonInclude(value = JsonInclude.Include.NON_NULL)
@NoArgsConstructor
@AllArgsConstructor
public class DataResponse<D> {

    @ApiModelProperty(value = "业务状态")
    @JsonProperty(value = "status", required = true)
    @Getter
    private DataStatus dataStatus;

    @ApiModelProperty(value = "接口返回消息，可用作弹出提示")
    @Getter
    private String notes = "";

    @ApiModelProperty(value = "响应客户端的具体业务数据结构")
    @Getter
    private D response;

    @ApiModelProperty(value = "分页信息，通常只会在返回列表数据时有值")
    @Getter
    private DataPage pages;

    public DataResponse(DataStatus dataStatus, String notes, D response) {
        this.dataStatus = dataStatus;
        this.notes = notes;
        this.response = response;
    }

    public DataResponse(DataStatus dataStatus, D response) {

        this.dataStatus = dataStatus;
        this.response = response;
    }

    public DataResponse<D> setDataStatus(DataStatus dataStatus) {
        this.dataStatus = dataStatus;
        return this;
    }

    public DataResponse<D> setNotes(String notes) {
        this.notes = notes;
        return this;
    }

    public DataResponse<D> setResponse(D response) {
        this.response = response;
        return this;
    }

    public DataResponse<D> setPages(DataPage pages) {
        this.pages = pages;
        return this;
    }
}
